home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 129_01.zip / 210CTDL.C < prev    next >
Text File  |  1993-06-01  |  22KB  |  861 lines

  1. /************************************************************************/
  2. /*                ctdl.c                    */
  3. /*        Command-interpreter code for Citadel            */
  4. /************************************************************************/
  5. #include <210ctdl.h>
  6. /************************************************************************/
  7. /*                history                 */
  8. /*                                    */
  9. /* 84Dec28 HAW    doAide modified to list deleted rooms.            */
  10. /* 84Dec21 HAW    doHelp fixed so that LONG filenames don't bomb system.    */
  11. /* 84Dec12 HAW    Fixed kill acct. bug that made killed acct. the user.    */
  12. /* 84Aug23 HAW & JLS  JLS's Forget scheme implemented.            */
  13. /* 84JuL12 HAW & JLS  <S>kip implemented.                */
  14. /* 84JuL06 HAW    ALL FILES: make putChar the bottleneck!         */
  15. /* 84Jun26 JLS & HAW  Commented out extra params to putRoom & getRoom.    */
  16. /* 84Jun21 JLS    Fix ".Read" so can't have endless "reverse forward..."    */
  17. /* 84Jun10 JLS    Implement "user must log in to create room."        */
  18. /* 84Jun10 JLS    Mod for changing date from other than system console.    */
  19. /* 84May18 JLS/HAW Greeting modified for coherency.            */
  20. /* 84Apr04 HAW    Upgrade to BDS 1.50a begun.                */
  21. /* 83Mar08 CrT    Aide-special functions installed & tested...        */
  22. /* 83Feb24 CrT/SB Menus rearranged.                    */
  23. /* 82Dec06 CrT    2.00 release.                        */
  24. /* 82Nov05 CrT    removed main() from room2.c and split into sub-fn()s    */
  25. /************************************************************************/
  26.  
  27. /************************************************************************/
  28. /*                Contents                */
  29. /*                                    */
  30. /*    doAide()        handles Aide-only commands        */
  31. /*    doChat()        handles C(hat)        command     */
  32. /*    doEnter()        handles E(nter)     command     */
  33. /*    doForget()        handles Z(Forget room)    command     */
  34. /*    doGoto()        handles G(oto)        command     */
  35. /*    doHelp()        handles H(elp)        command     */
  36. /*    doKnown()        handles K(nown rooms)    command     */
  37. /*    doLogin()        handles L(ogin)     command     */
  38. /*    doLogout()        handles T(erminate)    command     */
  39. /*    doRead()        handles R(ead)        command     */
  40. /*    doRegular()        fanout for above commands        */
  41. /*    doSkip()        handles S(kip)        command     */
  42. /*    doSysop()        handles sysop-only commands        */
  43. /*    getCommand()        prints prompt and gets command char    */
  44. /*    greeting()        System-entry blurb etc            */
  45. /*    main()            has the central menu code        */
  46. /************************************************************************/
  47.  
  48. /************************************************************************/
  49. /*    doAide() handles the aide-only menu                */
  50. /*        return FALSE to fall invisibly into default error msg    */
  51. /************************************************************************/
  52. char doAide(moreYet, first)
  53. char moreYet;
  54. char first;    /* first parameter if TRUE        */
  55. {
  56.     char oldName[NAMESIZE];
  57.     int  rm;
  58.  
  59.     if (!aide)     return FALSE;
  60.  
  61.     if (moreYet)   first = '\0';
  62.  
  63.     mprintf("ide special fn: ");
  64.  
  65.     if (first)       oChar(first);
  66.  
  67.     switch (toUpper(   first ? first : iChar()      )) {
  68.     case 'D':
  69.     sprintf(msgBuf.mbtext,
  70.        "The following empty rooms deleted by %s: ", logBuf.lbname);
  71.     mPrintf("elete empty rooms\n ");
  72.     strCpy(oldName, roomBuf.rbname);
  73.     indexRooms();
  74.  
  75.     if ((rm=roomExist(oldName)) != ERROR)    getRoom(rm);
  76.     else                    getRoom(LOBBY);
  77.  
  78.     aideMessage( /* noteDeletedMessage== */ FALSE );
  79.     break;
  80.     case 'E':
  81.     mprintf("dit room\n  \n");
  82.     strCpy(oldName, roomBuf.rbname);
  83.     if (!renameRoom())   break;
  84.     sPrintf(
  85.         msgBuf.mbtext,
  86.         "%s> edited to %s> by %s",
  87.         oldName,
  88.         roomBuf.rbname,
  89.         logBuf.lbname
  90.     );
  91.     aideMessage( /* noteDeletedMessage == */ FALSE);
  92.     break;
  93.     case 'S':
  94.     mprintf("et Date\n ");
  95.     changedate();
  96.     break;
  97.     case 'I':
  98.     mPrintf("nsert message\n ");
  99.     if (
  100.         thisRoom   == AIDEROOM
  101.         ||
  102.         pulledMLoc == ERROR
  103.     )   {
  104.         mPrintf("nope!");
  105.         break;
  106.     }
  107.     note2Message(pulledMId, pulledMLoc);
  108.     putRoom(thisRoom);
  109.     noteRoom();
  110.     sPrintf(
  111.         msgBuf.mbtext,
  112.         "Following message inserted in %s> by %s",
  113.         roomBuf.rbname,
  114.         logBuf.lbname
  115.     );
  116.     aideMessage( /* noteDeletedMessage == */ TRUE);
  117.     break;
  118.     case 'K':
  119.     mPrintf("ill room\n ");
  120.     if (
  121.         thisRoom == LOBBY
  122.         ||
  123.         thisRoom == MAILROOM
  124.         ||
  125.         thisRoom == AIDEROOM
  126.     ) {
  127.         mPrintf(" not here!");
  128.         break;
  129.     }
  130.     if (!getYesNo("confirm"))   break;
  131.  
  132.     sPrintf(
  133.         msgBuf.mbtext,
  134.         "%s> killed by %s",
  135.         roomBuf.rbname,
  136.         logBuf.lbname
  137.     );
  138.     aideMessage( /* noteDeletedMessage == */ FALSE);
  139.  
  140.     roomBuf.rbflags ^= INUSE;
  141.     putRoom(thisRoom);
  142.     noteRoom();
  143.     getRoom(LOBBY);
  144.     break;
  145.     case '?':
  146.     tutorial("aide.mnu");
  147.     break;
  148.     default:
  149.     if (!expert)    mprintf(" ?(Type '?' for menu)\n "    );
  150.     else        mprintf(" ?\n "             );
  151.     break;
  152.     }
  153.     return TRUE;
  154. }
  155.  
  156. /************************************************************************/
  157. /*    doChat()                            */
  158. /************************************************************************/
  159. doChat(moreYet, first)
  160. char moreYet;    /* TRUE to accept folliwng parameters    */
  161. char first;    /* first parameter if TRUE        */
  162. {
  163.     if (moreYet)   first = '\0';
  164.  
  165.     if (first)       oChar(first);
  166.  
  167.     mPrintf("hat ");
  168.  
  169.     if (noChat)   {
  170.     tutorial("nochat.blb");
  171.     return;
  172.     }
  173.  
  174.     if (whichIO == MODEM)    ringSysop();
  175.     else            interact() ;
  176. }
  177.  
  178. /************************************************************************/
  179. /*    doEnter() handles E(nter) command                */
  180. /************************************************************************/
  181. doEnter(moreYet, first)
  182. char moreYet;    /* TRUE to accept following parameters    */
  183. char first;    /* first parameter if TRUE        */
  184. {
  185. #define CONFIGURATION    0
  186. #define MESSAGE     1
  187. #define PASSWORD    2
  188. #define ROOM        3
  189. #define FILE        4
  190.     char what;            /* one of above five */
  191.     char abort, done, WC;
  192.     char iChar(), toUpper();
  193.  
  194.  
  195.     if (moreYet)   first = '\0';
  196.  
  197.     abort    = FALSE  ;
  198.     done    = FALSE  ;
  199.     WC        = FALSE  ;
  200.     what    = MESSAGE;
  201.  
  202.     mprintf("nter ");
  203.  
  204.     if (!loggedIn  &&  !unlogLoginOk  &&  thisRoom!=MAILROOM)    {
  205.     mprintf("--Must log in to enter (except in Mail>)\n ");
  206.     return;
  207.     }
  208.  
  209.     if (first)       oChar(first);
  210.  
  211.     do    {
  212.     outFlag = OUTOK;
  213.  
  214.     switch (toUpper(   first ? first : iChar()   )) {
  215.     case '\r':
  216.     case '\n':
  217.         moreYet    = FALSE;
  218.         break;
  219.     case 'F':
  220.         if (roomBuf.rbflags & CPMDIR) {
  221.         mprintf("ile upload ");
  222.         what    = FILE;
  223.         done    = TRUE;
  224.         break;
  225.         }
  226.     default:
  227.         mprintf("? ");
  228.         abort    = TRUE;
  229.         if (expert)  break;
  230.     case '?':
  231.         tutorial("entopt.mnu");
  232.         abort    = TRUE;
  233.         break;
  234.     case 'C':
  235.         mprintf("onfiguration ");
  236.         what    = CONFIGURATION;
  237.         done    = TRUE;
  238.         break;
  239.     case 'F':
  240.         mprintf("ile upload "    );
  241.         WC        = TRUE;
  242.         done    = TRUE;
  243.         break;
  244.     case 'M':
  245.         mprintf("essage "       );
  246.         what    = MESSAGE;
  247.         done    = TRUE;
  248.         break;
  249.     case 'P':
  250.         mprintf("assword "       );
  251.         what    = PASSWORD     ;
  252.         done    = TRUE;
  253.         break;
  254.     case 'R':
  255.         mprintf("oom "       );
  256.         if (!nonAideRoomOk && !aide)   {
  257.         mPrintf(" ?-- must be aide to create room\n ");
  258.         abort    = TRUE;
  259.         break;
  260.         }
  261.         if (!loggedIn) {
  262.         mprintf("!Must log in to create a new room\n");
  263.         abort = TRUE;
  264.         break;
  265.         }
  266.         what    = ROOM;
  267.         done    = TRUE;
  268.         break;
  269.     }
  270.     first = '\0';
  271.     } while (!done && moreYet && !abort);
  272.  
  273.     doCR();
  274.  
  275.     if (!abort) {
  276.     if (whichIO != CONSOLE && thisRoom == MAILROOM) echo = CALLER;
  277.     switch (what) {
  278.     case CONFIGURATION  :    configure()       ;       break;
  279.     case MESSAGE        :    makeMessage(WC, 0) ;       break;
  280.     case PASSWORD        :    newPW()        ;       break;
  281.     case ROOM        :    makeRoom()       ;       break;
  282.     case FILE        :    upLoad()       ;       break;
  283.     }
  284.     echo = BOTH;
  285.     }
  286. }
  287.  
  288. /************************************************************************/
  289. /*    doForget() handles (Forget room) command            */
  290. /************************************************************************/
  291. doForget(expand, first)
  292. char expand, first;
  293. {
  294.     int i;
  295.  
  296.     if (!expand) {
  297.     mPrintf("\bForget %s \n ", roomBuf.rbname);
  298.     if (thisRoom == LOBBY     ||
  299.         thisRoom == MAILROOM ||
  300.         thisRoom == AIDEROOM) {
  301.         mPrintf("!Can't forget this room! \n ");
  302.         return ;
  303.     }
  304.     if (!getYesNo("confirm"))   return;
  305.     i = (roomBuf.rbgen + FORGET_OFFSET) % MAXGEN;        /* Set up offset */
  306.     logBuf.lbgen[thisRoom] = i << GENSHIFT;         /* Save it         */
  307.     gotoRoom("Lobby", 'S');
  308.     }
  309.     else {
  310.     mPrintf("\b\b");
  311.     listRooms(/* doDull == */ FORGOT);
  312.     }
  313. }
  314.  
  315. /************************************************************************/
  316. /*    doGoto() handles G(oto) command                 */
  317. /************************************************************************/
  318. doGoto(expand, first)
  319. char expand;    /* TRUE to accept following parameters    */
  320. char first;    /* first parameter if TRUE        */
  321. {
  322.     char roomName[NAMESIZE];
  323.  
  324.     mprintf("oto ");
  325.  
  326.     if (!expand) {
  327.     gotoRoom("", 'R');
  328.     return;
  329.     }
  330.  
  331.     getNormStr("", roomName, NAMESIZE);
  332.  
  333.     if (roomName[0] == '?')    listRooms(/* doDull== */ ALMOST_ALL);
  334.     else            gotoRoom(roomName, 'R');
  335. }
  336.  
  337. /************************************************************************/
  338. /*    doHelp() handles H(elp) command                 */
  339. /************************************************************************/
  340. doHelp(expand, first)
  341. char expand;    /* TRUE to accept following parameters    */
  342. char first;    /* first parameter if TRUE        */
  343. {
  344.     char fileName[NAMESIZE];
  345.  
  346.     mprintf("elp ");
  347.     if (!expand) {
  348.     mprintf("\n\n");
  349.     tutorial("dohelp.hlp");
  350.     return;
  351.     }
  352.  
  353.     getNormStr("", fileName, 9);    /* CP/M filename size is 8    */
  354.     if (strlen(fileName) == 0)
  355.     strcpy(fileName, "dohelp");
  356.     if (fileName[0] == '?')    tutorial("helpopt.hlp");
  357.     else {
  358.     /* adding the extention makes things look simpler for        */
  359.     /* the user... and restricts the files which can be read    */
  360.     strcat(fileName, ".hlp");
  361.     tutorial(fileName);
  362.     }
  363. }
  364.  
  365. /************************************************************************/
  366. /*    doKnown() handles K(nown rooms) command.            */
  367. /************************************************************************/
  368. doKnown(expand, first)
  369. char expand;    /* TRUE to accept following parameters    */
  370. char first;    /* first parameter if TRUE        */
  371. {
  372.     mprintf("nown rooms\n ");
  373.     listRooms(/* doDull== */ ALMOST_ALL);
  374. }
  375.  
  376. /************************************************************************/
  377. /*    doLogin() handles L(ogin) command                */
  378. /************************************************************************/
  379. doLogin(moreYet, first)
  380. char moreYet;    /* TRUE to accept following parameters    */
  381. char first;    /* first parameter if TRUE        */
  382. {
  383.     char passWord[NAMESIZE];
  384.  
  385.     mprintf("ogin ");
  386.     if (!moreYet)   mPrintf("\n");
  387.     if (loggedIn)   {
  388.     mprintf("\n ?Already logged in!\n ");
  389.     return;
  390.     }
  391.     echo    = CALLER;
  392.     getNormStr(moreYet ? "" : " password", passWord, NAMESIZE);
  393.     echo    = BOTH;
  394.     login(passWord);
  395. }
  396.  
  397. /************************************************************************/
  398. /*    doLogout() handles T(erminate) command                */
  399. /************************************************************************/
  400. doLogout(expand, first)
  401. char expand;    /* TRUE to accept following parameters    */
  402. char first;    /* first parameter if TRUE        */
  403. {
  404.     char iChar(), toUpper();
  405.  
  406.     if (expand)   first = '\0';
  407.  
  408.     mprintf("erminate ");
  409.  
  410.     if (first)     oChar(first);
  411.  
  412.     switch (toUpper(    first ? first : iChar()    )) {
  413.     case '?':
  414.     mprintf("\n Logout options:\n \n ");
  415.  
  416.     mprintf("Quit-also\n "        );
  417.     mprintf("Stay\n "        );
  418.     break;
  419.     case 'Q':
  420.     mprintf("uit-also\n ");
  421.     if (!expand)   {
  422.        if (!getYesNo("confirm"))   break;
  423.     }
  424.     terminate( /* hangUp == */ TRUE);
  425.     break;
  426.     case 'S':
  427.     mprintf("tay\n ");
  428.     terminate( /* hangUp == */ FALSE);
  429.     break;
  430.     }
  431. }
  432.  
  433. /************************************************************************/
  434. /*    doRead() handles R(ead) command                 */
  435. /************************************************************************/
  436. doRead(moreYet, first)
  437. char moreYet;    /* TRUE to accept following parameters    */
  438. char first;    /* first parameter if TRUE        */
  439. {
  440.     char iChar(), toUpper();
  441.     int  fileDir(), transmitFile();
  442.     char abort, doDir, done, hostFile, whichMess, revOrder, status, WC;
  443.     char fileName[NAMESIZE];
  444.  
  445.  
  446.     if (moreYet)   first = '\0';
  447.  
  448.     mprintf("\bread ");
  449.  
  450.     if (!loggedIn  &&  !unlogReadOk)   {
  451.     mPrintf("Must log in to read\n ");
  452.     return;
  453.     }
  454.  
  455.     if (first)       oChar(first);
  456.  
  457.     abort    = FALSE;
  458.     doDir    = FALSE;
  459.     hostFile    = FALSE;
  460.     revOrder    = FALSE;
  461.     status    = FALSE;
  462.     WC        = FALSE;
  463.     whichMess    = NEWoNLY;
  464.  
  465.     do {
  466.     outFlag = OUTOK;
  467.     done = TRUE;
  468.  
  469.     switch (toUpper(   first ? first : iChar()   )) {
  470.     case '\n':
  471.     case '\r':
  472.         moreYet    = FALSE;
  473.         break;
  474.     case 'A':
  475.         mprintf("ll");
  476.         whichMess    = OLDaNDnEW;
  477.         break;
  478.     case 'F':
  479.         mprintf("orward");
  480.         revOrder    = FALSE;
  481.         whichMess    = OLDaNDnEW;
  482.         break;
  483.     case 'G':
  484.         mPrintf("lobal new-messages");
  485.         whichMess    = GLOBALnEW;
  486.         break;
  487.     case 'N':
  488.         mprintf("ew ");
  489.         whichMess    = NEWoNLY;
  490.         break;
  491.     case 'O':
  492.         mPrintf("ld Reverse");
  493.         revOrder    = TRUE;
  494.         whichMess    = OLDoNLY;
  495.         break;
  496.     case 'R':
  497.         mprintf("everse");
  498.         revOrder    = TRUE;
  499.         whichMess    = OLDaNDnEW;
  500.         break;
  501.     case 'S':
  502.         mprintf("tatus\n ");
  503.         status    = TRUE;
  504.         break;
  505.     case 'W':
  506.         mprintf("C protocol ");
  507.         WC        = TRUE;
  508.         done    = FALSE;
  509.         break;
  510.     case 'B':
  511.         if (roomBuf.rbflags & CPMDIR)   {
  512.         mprintf("inary file(s) ");
  513.         hostFile    = TRUE ;
  514.         textDownload    = FALSE;
  515.         break;
  516.         }
  517.     case 'D':
  518.         if (roomBuf.rbflags & CPMDIR)   {
  519.         mprintf("irectory ");
  520.         doDir    = TRUE;
  521.         break;
  522.         }
  523.     case 'T':
  524.         if (roomBuf.rbflags & CPMDIR)   {
  525.         mprintf("extfile(s) ");
  526.         hostFile    = TRUE;
  527.         textDownload    = TRUE;
  528.         break;
  529.         }
  530.     default:
  531.         mprintf("? ");
  532.         abort    = TRUE;
  533.         setUp(FALSE);
  534.         if (expert)   break;
  535.     case '?':
  536.         tutorial("readopt.mnu");
  537.         abort    = TRUE;
  538.         break;
  539.     }
  540.     first = '\0';
  541.     } while (!done && moreYet && !abort);
  542.  
  543.     if (abort) return;
  544.  
  545.     if (status) {
  546.     systat();
  547.     return;
  548.     }
  549.  
  550.     if (doDir) {
  551.     FDSectCount    = 0;    /* global fileDir() totals sectors in    */
  552.  
  553.     getNormStr("", fileName, NAMESIZE);
  554.  
  555.     if (strLen(fileName))    wildCard(fileDir, fileName);
  556.     else            wildCard(fileDir, "*.*"   );
  557.  
  558.     mprintf("\n %d sectors total\n ", FDSectCount);
  559.     return;
  560.     }
  561.  
  562.     if (hostFile) {
  563.     getNormStr("afn", fileName, NAMESIZE);
  564.     usingWCprotocol = WC;
  565.     wildCard(transmitFile, fileName);
  566.     usingWCprotocol = FALSE;
  567.     return;
  568.     }
  569.  
  570.     doCR();
  571.     if (WC) {
  572.     download(whichMess, revOrder);
  573.     return;
  574.     }
  575.  
  576.     if (whichMess != GLOBALnEW)   {
  577.     showMessages(whichMess, revOrder);
  578.     } else {
  579.     while (outFlag != OUTSKIP   &&     gotoRoom("", 'R'))   {
  580.         givePrompt();
  581.         mPrintf("read new\n ");
  582.         showMessages(NEWoNLY, revOrder);
  583.     }
  584.     }
  585. }
  586.  
  587. /************************************************************************/
  588. /*    doRegular()                            */
  589. /************************************************************************/
  590. char doRegular(x, c)
  591. char x, c;
  592. {
  593.     char toReturn;
  594.  
  595.     toReturn = FALSE;
  596.  
  597.     switch (c) {
  598.  
  599.     case 'C': doChat(  x, '\0');            break;
  600.     case 'E': doEnter( x, 'm' );            break;
  601.     case 'F': doRead(  x, 'f' );            break;
  602.     case 'G': doGoto(  x, '\0');            break;
  603.     case 'H': doHelp(  x, '\0');            break;
  604.     case 'K': doKnown( x, '\0');            break;
  605.     case 'L': doLogin( x, '\0');            break;
  606.     case 'N': doRead(  x, 'n' );            break;
  607.     case 'O': doRead(  x, 'o' );            break;
  608.     case 'R': doRead(  x, 'r' );            break;
  609.     case 'S': doSkip(  x, '\0');            break;
  610.     case 'T': doLogout(x, 'q' );            break;
  611.  
  612.     case 0:
  613.     if (newCarrier)   {
  614.         greeting();
  615.         newCarrier    = FALSE;
  616.     }
  617.     if (justLostCarrier) {
  618.         justLostCarrier = FALSE;
  619.         if (loggedIn) terminate(FALSE);
  620.     }
  621.     break;    /* irrelevant value */
  622.     case '?':
  623.     tutorial("mainopt.mnu");
  624.     if (whichIO == CONSOLE)   mprintf(" ^p: privileged fns\n ");
  625.     break;
  626.  
  627.     case 'A': if (!doAide(x, 'E'))  toReturn=TRUE;    break;
  628.     case 'Z': doForget(x, '\0');              break;
  629.     default:
  630.     toReturn=TRUE;
  631.     break;
  632.     }
  633.     return  toReturn;
  634. }
  635.  
  636. /************************************************************************/
  637. /*    doSkip() handles the <S>kip a room command            */
  638. /************************************************************************/
  639. char doSkip(expand, first)
  640. char first, expand;
  641. {
  642.     char roomName[NAMESIZE];        /* In case of ".Skip" */
  643.  
  644.     mPrintf("kip %s> goto ", roomTab[thisRoom].rtname);
  645.     if (expand)
  646.     getString("", roomName, NAMESIZE);
  647.     else
  648.     roomName[0] = '\0';
  649.     if (roomName[0] == '?')
  650.     tutorial("skip.hlp");
  651.     else {
  652.     roomTab[thisRoom].rtflags |= SKIP;    /* Set bit */
  653.     gotoRoom(roomName, 'S');
  654.     }
  655. }
  656.  
  657. /************************************************************************/
  658. /*    doSysop() handles the sysop-only menu                */
  659. /*        return FALSE to fall invisibly into default error msg    */
  660. /************************************************************************/
  661. char doSysop(c, first)
  662. char c;
  663. char first;    /* first parameter if TRUE        */
  664. {
  665.     char        who[NAMESIZE];
  666.     struct logBuffer    lBuf;
  667.     int         logNo, ltabSlot;
  668.  
  669.     if (!onConsole)   return TRUE;
  670.  
  671.     while (TRUE)   {
  672.  
  673.     mprintf("\n privileged fn: ");
  674.  
  675.     switch (toUpper(   first ? first : iChar()    )) {
  676.     case 'A':
  677.         mPrintf("bort\n ");
  678.         return FALSE;
  679.     case 'C':
  680.         mprintf("hat mode %sabled\n ",
  681.         (noChat = !noChat)
  682.         ?
  683.         "dis"
  684.         :
  685.         "en"
  686.         );
  687.         break;
  688.     case 'D':
  689.         debug = !debug;
  690.         mprintf("ebug switch=%d\n \n", debug);
  691.         break;
  692.     case 'K':
  693.         mPrintf("ill account\n ");
  694.         if (!getYesNo("Confirm"))    break;
  695.         getNormStr("who", who, NAMESIZE);
  696.         logNo   = findPerson(who, &lBuf);
  697.         if (logNo == ERROR)   {
  698.         mPrintf("No such person\n ");
  699.         break;
  700.         }
  701.         mPrintf(
  702.         "%s deleted\n ",
  703.         who
  704.         );
  705.         ltabSlot = PWSlot(lBuf.lbpw, /* load == */ FALSE);
  706.         lBuf.lbname[0] = '\0';
  707.         lBuf.lbpw[0  ] = '\0';
  708.  
  709.         putLog(&lBuf, logNo);
  710.  
  711.         logTab[ltabSlot].ltpwhash        = 0;
  712.         logTab[ltabSlot].ltnmhash        = 0;
  713.  
  714.         break;
  715.     case 'M':
  716.         mprintf("\bSystem now on MODEM\n ");
  717.         whichIO = MODEM;
  718.         setUp(FALSE);
  719.         mprintf("Chat mode %sabled\n ", noChat  ?  "dis"  :  "en");
  720.         if (debug)         mPrintf("Debug mode on\n "  );
  721.         if (visibleMode) mPrintf("Visible mode on\n ");
  722.         return FALSE;
  723.     case 'P':
  724.         mPrintf("\baide privilege set/clear\n ");
  725.         getNormStr("who", who, NAMESIZE);
  726.         logNo   = findPerson(who, &lBuf);
  727.         if (logNo == ERROR)   {
  728.         mPrintf("No such person\n ");
  729.         break;
  730.         }
  731.  
  732.         lBuf.lbflags ^= AIDE;
  733.         mPrintf(
  734.         "%s %s aide privileges\n ",
  735.         who,
  736.         (lBuf.lbflags & AIDE)  ?  "gets"  :  "loses"
  737.         );
  738.         if (!getYesNo("Confirm"))    break;
  739.  
  740.         putLog(&lBuf, logNo);
  741.  
  742.         /* see if it is us: */
  743.         if (loggedIn  &&  strCmpU(logBuf.lbname, who)==SAMESTRING)     {
  744.         aide = lBuf.lbflags & AIDE;
  745.         logBuf.lbflags ^= AIDE;
  746.         }
  747.         break;
  748. #ifdef XYZZY
  749.     case 'R':
  750.         patchDebug();
  751.         break;
  752. #endif
  753.     case 'S':
  754.         changeDate();
  755.         break;
  756.     case 'V':
  757.         mprintf(" VisibleMode==%d\n ",  visibleMode = !visibleMode);
  758.         break;
  759.     case 'X':
  760.         mprintf("\bexit to CP/M\n \n");
  761.         exitToCpm = TRUE;
  762.         return FALSE;
  763.     case '?':
  764.         tutorial("ctdlopt.mnu");
  765.         break;
  766.     default:
  767.         if (!expert)    mprintf(" ?(Type '?' for menu)\n "        );
  768.         else        mprintf(" ?\n "                );
  769.         break;
  770.     }
  771.     }
  772. }
  773.  
  774. /************************************************************************/
  775. /*    getCommand() prints menu prompt and gets command char        */
  776. /*    Returns: char via parameter and expand flag as value  --    */
  777. /*         i.e., TRUE if parameters follow else FALSE.        */
  778. /************************************************************************/
  779. char getCommand(c)
  780. char *c;
  781. {
  782.     char BBSCharReady(), iChar(), toUpper();
  783.     char expand;
  784.  
  785.     outFlag = OUTOK;
  786.  
  787.   /*if (*c)*/ givePrompt();
  788.     while (BBSCharReady())   iChar();          /* eat type-ahead       */
  789.  
  790.     *c = toUpper(iChar());
  791.  
  792.     expand  = (
  793.     *c == ' '
  794.     ||
  795.     *c == '.'
  796.     ||
  797.     *c == ','
  798.     ||
  799.     *c == '/'
  800.     );
  801.     if (expand) *c = toUpper(iChar());
  802.  
  803.     if (justLostCarrier) {
  804.     justLostCarrier = FALSE;
  805.     if (loggedIn) terminate(FALSE);
  806.     }
  807.     return expand;
  808. }
  809.  
  810. /************************************************************************/
  811. /*    greeting() gives system-entry blurb etc             */
  812. /************************************************************************/
  813. greeting()
  814. {
  815.     if (loggedIn) terminate(FALSE);
  816.  
  817.     setUp(TRUE);     pause(10);
  818.  
  819.     mprintf("\n Welcome to %s", nodeTitle);
  820.     mprintf("\n Running: Citadel (V2.4) \n \n");
  821.     printDate();
  822.     mprintf("\n H for Help\n ");
  823.  
  824.     printf("Chat mode %sabled\n", noChat ? "dis" : "en");
  825.     printf("\n 'MODEM' mode.\n "               );
  826.     printf("(<ESC> for CONSOLE mode.)\n "           );
  827.  
  828.     gotoRoom("Lobby", 'R');
  829. }
  830.  
  831. /************************************************************************/
  832. /*    main() contains the central menu code                */
  833. /************************************************************************/
  834. main() {
  835.     char c, x;
  836.     char getCommand(), init();
  837.     int  putChar();        /* Force load from modem.c */
  838.     int  getNumber();        /* Force load */
  839.     int  doWC();
  840.     
  841.     /* don't put any code above init()... readSysTab() will defeat it.    */
  842.     init();
  843.     initCitadel();
  844.     weAre    = CITADEL;
  845.     greeting();
  846.  
  847.     while (!exitToCpm) {
  848.     x    = getCommand(&c);
  849.  
  850.     outFlag = OUTOK;
  851.  
  852.     if ((c==CNTRLp)  ?  doSysop(0, '\0')  :  doRegular(x, c))  {
  853.         if (!expert)    mprintf(" ? (Type '?' for menu)\n \n"   );
  854.         else        mprintf(" ?\n \n"                );
  855.     }
  856.     }
  857.     if (loggedIn) terminate( /* hangUp == */ TRUE);
  858.     writeSysTab(); 
  859. }
  860. sabled\n", noChat ? "dis" : "en");
  861.